package com.thti.mecool.client.widget;

import com.thti.mecool.client.activity.R;

import android.app.Activity;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;

public class Toolbar {
	Activity activity;
	public static  ImageButton left_btn;
	public static ImageButton right_btn;
	public TextView title;
	public EditText editText;

	public Toolbar(Activity activity) {
		this.activity = activity;
		initBtn();
	} 

	public void initBtn() {
		left_btn = (ImageButton) activity.findViewById(R.id.mecool_toolbar_leftbtn);
		right_btn = (ImageButton) activity.findViewById(R.id.mecool_toolbar_rightbtn);
		title = (TextView) activity.findViewById(R.id.mecool_toolbar_title);
		editText= (EditText) activity.findViewById(R.id.mecool_toolbar_edittext);
	}
	
	
	/**
	 * 隐藏编辑栏
	 */
	public void hideEditText() {
		editText.setVisibility(View.GONE);
	}
	/**
	 * 隐藏左边按钮
	 */
	public void hideLeftButton() {
		left_btn.setVisibility(View.GONE);
	}

	/**
	 * 隐藏中间文字
	 */
	public void hideCentreTextView() {
		title.setVisibility(View.GONE);
	}

	/**
	 * 隐藏右边按钮
	 */
	public static void hideRightButton() {
		right_btn.setVisibility(View.GONE);
	}

	/**
	 * 显示左边按钮
	 */
	public void showLeftButton() {
		left_btn.setVisibility(View.VISIBLE);
	}

	/**
	 * 显示中间文字
	 */
	public void showCentreTextView() {
		title.setVisibility(View.VISIBLE);
	}

	/**
	 * 显示右边按钮
	 */
	public void showRightButton() {
		right_btn.setVisibility(View.VISIBLE);
	}
	/**
	 * 显示编辑栏
	 */
	public void showEditText() {
		editText.setVisibility(View.VISIBLE);
	}
	/**
	 * 设置中间TextView的文字
	 * 
	 * @param text
	 */
	public void setToolbarCentreText(String text) {
		title.setText(text);
	}

	public void setimage(ImageButton imgBtn, int drawable) {
		imgBtn.setImageResource(drawable);
	}
}
